<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">

	</head>

	<body>
		<p>获得问候</p>
		<button onclick="myFunction()">点击这里</button>
		<p id="demo"></p>
		<script type="text/javascript">
			function myFunction() {
				var x = "";
				var time = new Date().getHours();
				if(time < 10) {
					x = "早上好"
				} else if (time<16){
					x = "美好的一天";
				} else {
					x = "Good evening";
				}
				document.getElementById("demo").innerHTML = x;
			}
		</script>
	</body>

</html>